<!DOCTYPE html>
<html lang="en" color-mode="light">

  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="keywords" content="JavaScript,Hexo" />
  <meta name="author" content="超能虾米" />
  <meta name="description" content="" />
  
  
  <title>
    
      frp实现内网穿透 
      
      
      |
    
     超能虾米的博客
  </title>

  
    <link rel="apple-touch-icon" href="/images/favicon.png">
    <link rel="icon" href="/images/favicon.png">
  

  <!-- Raleway-Font -->
  <link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">

  <!-- hexo site css -->
  <link rel="stylesheet" href="/css/main.css" />
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1886449_67xjft27j1l.css" />
  <!-- 代码块风格 -->
  

  <!-- jquery3.3.1 -->
  
    <script defer type="text/javascript" src="/plugins/jquery.min.js"></script>
  

  <!-- fancybox -->
  
    <link href="/plugins/jquery.fancybox.min.css" rel="stylesheet">
    <script defer type="text/javascript" src="/plugins/jquery.fancybox.min.js"></script>
  
  
<script src="/js/fancybox.js"></script>


  

  

  <script>
    var html = document.documentElement
    const colorMode = localStorage.getItem('color-mode')
    if (colorMode) {
      document.documentElement.setAttribute('color-mode', colorMode)
    }
  </script>
<meta name="generator" content="Hexo 5.4.2"><link rel="alternate" href="/atom.xml" title="超能虾米的博客" type="application/atom+xml">
</head>


  <body>
    <div id="app">
      <div class="header">
  <div class="avatar">
    <a href="/">
      <!-- 头像取消懒加载，添加no-lazy -->
      
        <img src="/images/头像.JPEG" alt="">
      
    </a>
    <div class="nickname"><a href="/">超能虾米</a></div>
  </div>
  <div class="navbar">
    <ul>
      
        <li class="nav-item" data-path="/">
          <a href="/">主页</a>
        </li>
      
        <li class="nav-item" data-path="/archives/">
          <a href="/archives/">归档</a>
        </li>
      
        <li class="nav-item" data-path="/categories/">
          <a href="/categories/">分类</a>
        </li>
      
        <li class="nav-item" data-path="/tags/">
          <a href="/tags/">标签</a>
        </li>
      
        <li class="nav-item" data-path="/friends/">
          <a href="/friends/">朋友</a>
        </li>
      
        <li class="nav-item" data-path="/about/">
          <a href="/about/">关于我</a>
        </li>
      
    </ul>
  </div>
</div>


<script src="/js/activeNav.js"></script>



      <div class="flex-container">
        <!-- 文章详情页，展示文章具体内容，url形式：https://yoursite/文章标题/ -->
<!-- 同时为「标签tag」，「朋友friend」，「分类categories」，「关于about」页面的承载页面，具体展示取决于page.type -->


  <!-- LaTex Display -->

  
    <script async type="text/javascript" src="/plugins/mathjax/tex-chtml.js"></script>
  
  <script>
    MathJax = {
      tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']]
      }
    }
  </script>





  <!-- clipboard -->

  
    <script async type="text/javascript" src="/plugins/clipboard.min.js"></script>
  
  
<script src="/js/codeCopy.js"></script>







  

  

  

  
  <!-- 文章内容页 url形式：https://yoursite/文章标题/ -->
  <div class="container post-details" id="post-details">
    <div class="post-content">
      <div class="post-title">frp实现内网穿透</div>
      <div class="post-attach">
        <span class="post-pubtime">
          <i class="iconfont icon-updatetime mr-10" title="Update time"></i>
          2021-07-27 19:45:48
        </span>
        
              <span class="post-categories">
                <i class="iconfont icon-bookmark" title="Categories"></i>
                
                <span class="span--category">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/" title="工具">
                    <b>#</b> 工具
                  </a>
                </span>
                
                <span class="span--category">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/%E6%9D%82%E9%A1%B9/" title="杂项">
                    <b>#</b> 杂项
                  </a>
                </span>
                
              </span>
          
              <span class="post-tags">
                <i class="iconfont icon-tags mr-10" title="Tags"></i>
                
                <span class="span--tag mr-8">
                  <a href="/tags/%E5%B7%A5%E5%85%B7/" title="工具">
                    #工具
                  </a>
                </span>
                
                <span class="span--tag mr-8">
                  <a href="/tags/frp/" title="frp">
                    #frp
                  </a>
                </span>
                
                <span class="span--tag mr-8">
                  <a href="/tags/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/" title="内网穿透">
                    #内网穿透
                  </a>
                </span>
                
              </span>
          
      </div>
      <div class="markdown-body">
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>工作中遇到项目中需要开发公众号的情况，公众号平台需要指定域名，且要求端口需要是80或443端口才行。而公司的公网域名和端口已经被使用，为了方便开发调试，使用了frp来实现内网穿透。这里使用的frp版本为<code>0.35.1</code></p>
<h1 id="frp简介"><a href="#frp简介" class="headerlink" title="frp简介"></a>frp简介</h1><h2 id="frp是什么"><a href="#frp是什么" class="headerlink" title="frp是什么"></a>frp是什么</h2><p>frp 是一个高性能的反向代理应用，可以帮助您轻松地进行内网穿透，对外网提供服务，支持 tcp, http, https 等协议类型，并且 web 服务支持根据域名进行路由转发。</p>
<h2 id="frp-的作用"><a href="#frp-的作用" class="headerlink" title="frp 的作用"></a>frp 的作用</h2><ul>
<li>利用处于内网或防火墙后的机器，对外网环境提供 http 或 https 服务。</li>
<li>对于 http 服务支持基于域名的虚拟主机，支持自定义域名绑定，使多个域名可以共用一个80端口。</li>
<li>利用处于内网或防火墙后的机器，对外网环境提供 tcp 服务，例如在家里通过 ssh 访问处于公司内网环境内的主机。</li>
<li>可查看通过代理的所有 http 请求和响应的详细信息。（待开发）</li>
</ul>
<h2 id="frp的架构"><a href="#frp的架构" class="headerlink" title="frp的架构"></a>frp的架构</h2><p><img src="https://img-blog.csdnimg.cn/20210205154405707.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjE3NzMwMg==,size_16,color_FFFFFF,t_70" alt="frp的架构"></p>
<h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2><ol>
<li><p><strong>有公网ip的设备（云服务器，VPS都可以）</strong></p>
</li>
<li><p><strong>保证公网设备响应的端口要对外开启，如果是云服务器则到响应的云服务器产商的控制台中开启，以供后续使用</strong></p>
</li>
<li><p><strong>如果有使用域名的需求的话，记得将域名映射到公网ip</strong></p>
</li>
</ol>
<h2 id="frp下载地址"><a href="#frp下载地址" class="headerlink" title="frp下载地址"></a>frp下载地址</h2><p>github页面地址：<a target="_blank" rel="noopener" href="https://github.com/fatedier/frp/releases">https://github.com/fatedier/frp/releases</a><br><img src="https://img-blog.csdnimg.cn/20210205142940274.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjE3NzMwMg==,size_16,color_FFFFFF,t_70" alt="frp下载"><br>跟据自己的机器下载对应的版本就好~不然不兼容版本无法运行！！<br>我下载的是：<br>linux服务器：<a target="_blank" rel="noopener" href="https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz">frp_0.35.1_linux_amd64.tar.gz</a><br>windows内网机器：<a target="_blank" rel="noopener" href="https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_windows_amd64.zip">frp_0.35.1_windows_amd64.zip</a></p>
<p>如果是32位系统就选386结尾的！</p>
<h2 id="frp的文件结构"><a href="#frp的文件结构" class="headerlink" title="frp的文件结构"></a>frp的文件结构</h2><p>以windows版本为例<br><img src="https://img-blog.csdnimg.cn/20210205144552881.png" alt="frp文件结构"><br>可以看出，frp中包含了frpc和frps，c即client客户端，s即server服务端。</p>
<p>frpc.ini、frps.ini 分别是客户端的配置文件和服务端的配置文件，修改配置也是在这里修改</p>
<p>一般情况下公网机器上只用运行frps，内网机器只用运行frpc</p>
<h1 id="frp配置与使用"><a href="#frp配置与使用" class="headerlink" title="frp配置与使用"></a>frp配置与使用</h1><h2 id="linux公网服务器的配置-windows配置同理，这里不做说明"><a href="#linux公网服务器的配置-windows配置同理，这里不做说明" class="headerlink" title="linux公网服务器的配置(windows配置同理，这里不做说明)"></a>linux公网服务器的配置(windows配置同理，这里不做说明)</h2><p>1、下载frp文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz</span><br></pre></td></tr></table></figure>
<p>2、下载完后解压压缩包</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ tar -zxvf frp_0.35.1_linux_amd64.tar.gz</span><br></pre></td></tr></table></figure>
<p>3、根据需求修改配置（见下文）</p>
<p>4、启动frps</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ <span class="built_in">cd</span> frp_0.35.1_linux_amd64/ </span><br><span class="line">$ ./frps -c ./frps.ini</span><br></pre></td></tr></table></figure>

<h2 id="通过-ssh-访问公司内网机器"><a href="#通过-ssh-访问公司内网机器" class="headerlink" title="通过 ssh 访问公司内网机器"></a>通过 ssh 访问公司内网机器</h2><p><strong>1、 服务器端：修改 frps.ini 文件，配置一个名为 ssh 的反向代理：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># frps.ini</span></span><br><span class="line">[common]</span><br><span class="line">bind_port = 7000 <span class="comment">#该端口用于与内网通信</span></span><br><span class="line"></span><br><span class="line">[ssh]</span><br><span class="line">listen_port = 6000 <span class="comment">#该端口用于监听ssh请求</span></span><br><span class="line">auth_token = 123</span><br></pre></td></tr></table></figure>

<p><strong>2、 服务器端：启动 frps：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ./frps -c ./frps.ini</span><br></pre></td></tr></table></figure>

<p><strong>3、 客户端：修改 frpc.ini 文件：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># frpc.ini</span></span><br><span class="line">[common]</span><br><span class="line">server_addr = x.x.x.x <span class="comment">#frps 所在服务器的 IP</span></span><br><span class="line">server_port = 7000 <span class="comment">#frps 配置中bind_port的端口，两者要一直，不然怎么通信</span></span><br><span class="line">auth_token = 123</span><br><span class="line"></span><br><span class="line">[ssh]</span><br><span class="line">local_port = 22 <span class="comment">#本地ssh监听的端口</span></span><br></pre></td></tr></table></figure>

<p><strong>4、客户端：启动 frpc：</strong></p>
<p>1）linux系统的启动方式：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ./frpc -c ./frpc.ini</span><br></pre></td></tr></table></figure>
<p>2）windows系统需要cmd启动frpc.exe：<br><img src="https://img-blog.csdnimg.cn/20210205151509674.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjE3NzMwMg==,size_16,color_FFFFFF,t_70" alt="windows启动frpc.exe"></p>
<p><strong>5、 通过 ssh 访问内网机器，假设用户名为 test：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh -oPort=6000 <span class="built_in">test</span>@x.x.x.x</span><br></pre></td></tr></table></figure>

<h2 id="通过IP或指定域名访问部署于内网的-web-服务"><a href="#通过IP或指定域名访问部署于内网的-web-服务" class="headerlink" title="通过IP或指定域名访问部署于内网的 web 服务"></a>通过IP或指定域名访问部署于内网的 web 服务</h2><p>有时想要让其他人通过域名访问或者测试我们在本地搭建的 web 服务，但是由于本地机器没有公网 IP，无法将域名解析到本地的机器，通过 frp 就可以实现这一功能，以下示例为 http 服务，https 服务配置方法相同， vhost_http_port 替换为 vhost_https_port， type 设置为 https 即可。</p>
<p><strong>1、 修改 frps.ini 文件，配置一个名为 web 的 http 反向代理，设置 http 访问端口为 80，绑定IP或域名：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># frps.ini</span></span><br><span class="line">[common] </span><br><span class="line">bind_port = 7000 <span class="comment">#该端口用于与内网通信</span></span><br><span class="line">vhost_http_port = 80 <span class="comment">#公网访问的端口，如果是https，这里替换为vhost_https_port</span></span><br><span class="line"></span><br><span class="line">[web]</span><br><span class="line"><span class="built_in">type</span> = http <span class="comment">#如果是https，这里替换为https</span></span><br><span class="line">custom_domains = www.yourdomain.com <span class="comment">#这里是你的公网服务器IP或域名</span></span><br><span class="line">auth_token = 123</span><br></pre></td></tr></table></figure>

<blockquote>
<p>上述的 [web] 下的配置可以不要</p>
</blockquote>
<p><strong>2、 服务器端：启动 frps：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ./frps -c ./frps.ini</span><br></pre></td></tr></table></figure>

<p><strong>3、 客户端：修改 frpc.ini 文件：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># frpc.ini</span></span><br><span class="line">[common]</span><br><span class="line">server_addr = x.x.x.x <span class="comment">#frps 所在服务器的 IP</span></span><br><span class="line">server_port = 7000 <span class="comment">#frps 配置中bind_port的端口，两者要一直，不然怎么通信</span></span><br><span class="line">auth_token = 123</span><br><span class="line"></span><br><span class="line">[web]</span><br><span class="line"><span class="built_in">type</span> = http <span class="comment">#如果是https，这里替换为https</span></span><br><span class="line">local_port = 8080 <span class="comment">#内网环境web服务的端口</span></span><br><span class="line">custom_domains = www.yourdomain.com <span class="comment">#这里是你的公网服务器IP或域名，如果需要IP或域名同时可以访问，将IP和域名使用逗号分隔写到这里！！！！！！！！！！！</span></span><br></pre></td></tr></table></figure>

<p><strong>4、客户端：启动 frpc：</strong></p>
<p>1）linux系统的启动方式：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ./frpc -c ./frpc.ini</span><br></pre></td></tr></table></figure>
<p>2）windows系统需要cmd启动frpc.exe：<br><img src="https://img-blog.csdnimg.cn/20210205151509674.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjE3NzMwMg==,size_16,color_FFFFFF,t_70" alt="windows启动frpc.exe"></p>
<p><strong>5、通过浏览器访问 <a target="_blank" rel="noopener" href="http://www.yourdomain.com/">http://www.yourdomain.com</a></strong>(没有配域名这边就写ip地址)<strong>:端口</strong>(frps中vhost_http_port的值) <strong>即可访问到处于内网机器上的 web 服务。</strong></p>
<h2 id="更多配置"><a href="#更多配置" class="headerlink" title="更多配置"></a>更多配置</h2><p>DNS、提供文件服务等更多功能，可以参考<a target="_blank" rel="noopener" href="https://gitee.com/wefeng/frp">https://gitee.com/wefeng/frp</a></p>
<h1 id="小结"><a href="#小结" class="headerlink" title="小结"></a>小结</h1><p>frp是一款方便、快捷、高效的内网穿透工具，但是需要有公网IP的机器，而且访问速度同时受限于内网所处网络和公网机器网络的速度，不过平常使用已经是很不错的选择了。frp还有其他妙用，这里就不再赘述。</p>
<p>如果有帮到你，那就点赞支持下吧，或者有什么问题，还请留言或者私信~</p>

      </div>
      
        <div class="prev-or-next">
          <div class="post-foot-next">
            
          </div>
          <div class="post-attach">
            <span class="post-pubtime">
              <i class="iconfont icon-updatetime mr-10" title="Update time"></i>
              2021-07-27 19:45:48
            </span>
            
                  <span class="post-categories">
                    <i class="iconfont icon-bookmark" title="Categories"></i>
                    
                    <span class="span--category">
                      <a href="/categories/%E5%B7%A5%E5%85%B7/" title="工具">
                        <b>#</b> 工具
                      </a>
                    </span>
                    
                    <span class="span--category">
                      <a href="/categories/%E5%B7%A5%E5%85%B7/%E6%9D%82%E9%A1%B9/" title="杂项">
                        <b>#</b> 杂项
                      </a>
                    </span>
                    
                  </span>
              
                  <span class="post-tags">
                    <i class="iconfont icon-tags mr-10" title="Tags"></i>
                    
                    <span class="span--tag mr-8">
                      <a href="/tags/%E5%B7%A5%E5%85%B7/" title="工具">
                        #工具
                      </a>
                    </span>
                    
                    <span class="span--tag mr-8">
                      <a href="/tags/frp/" title="frp">
                        #frp
                      </a>
                    </span>
                    
                    <span class="span--tag mr-8">
                      <a href="/tags/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/" title="内网穿透">
                        #内网穿透
                      </a>
                    </span>
                    
                  </span>
              
          </div>
          <div class="post-foot-prev">
            
              <a href="/2021/07/31/%E5%90%8E%E7%AB%AF/Spring%20Boot/Spring-Boot%E8%87%AA%E5%8A%A8%E9%85%8D%E7%BD%AE%E5%8E%9F%E7%90%86/" target="_self">
                <span>Next</span>
                <i class="iconfont icon-chevronright"></i>
              </a>
            
          </div>
        </div>
      
    </div>
    
  <div id="btn-catalog" class="btn-catalog">
    <i class="iconfont icon-catalog"></i>
  </div>
  <div class="post-catalog hidden" id="catalog">
    <div class="title">Contents</div>
    <div class="catalog-content">
      
        <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E8%A8%80"><span class="toc-text">前言</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#frp%E7%AE%80%E4%BB%8B"><span class="toc-text">frp简介</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#frp%E6%98%AF%E4%BB%80%E4%B9%88"><span class="toc-text">frp是什么</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#frp-%E7%9A%84%E4%BD%9C%E7%94%A8"><span class="toc-text">frp 的作用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#frp%E7%9A%84%E6%9E%B6%E6%9E%84"><span class="toc-text">frp的架构</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="toc-text">准备工作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#frp%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80"><span class="toc-text">frp下载地址</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#frp%E7%9A%84%E6%96%87%E4%BB%B6%E7%BB%93%E6%9E%84"><span class="toc-text">frp的文件结构</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#frp%E9%85%8D%E7%BD%AE%E4%B8%8E%E4%BD%BF%E7%94%A8"><span class="toc-text">frp配置与使用</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#linux%E5%85%AC%E7%BD%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE-windows%E9%85%8D%E7%BD%AE%E5%90%8C%E7%90%86%EF%BC%8C%E8%BF%99%E9%87%8C%E4%B8%8D%E5%81%9A%E8%AF%B4%E6%98%8E"><span class="toc-text">linux公网服务器的配置(windows配置同理，这里不做说明)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%80%9A%E8%BF%87-ssh-%E8%AE%BF%E9%97%AE%E5%85%AC%E5%8F%B8%E5%86%85%E7%BD%91%E6%9C%BA%E5%99%A8"><span class="toc-text">通过 ssh 访问公司内网机器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%80%9A%E8%BF%87IP%E6%88%96%E6%8C%87%E5%AE%9A%E5%9F%9F%E5%90%8D%E8%AE%BF%E9%97%AE%E9%83%A8%E7%BD%B2%E4%BA%8E%E5%86%85%E7%BD%91%E7%9A%84-web-%E6%9C%8D%E5%8A%A1"><span class="toc-text">通过IP或指定域名访问部署于内网的 web 服务</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9B%B4%E5%A4%9A%E9%85%8D%E7%BD%AE"><span class="toc-text">更多配置</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93"><span class="toc-text">小结</span></a></li></ol>
      
    </div>
  </div>

  
<script src="/js/catalog.js"></script>




    
      <div class="comments-container">
        




  
    <script async type="text/javascript" src="/plugins/valine.min.js" onload="loadValineSuc(this)"></script>
  

  <div id="vcomments"></div>

  <script>
    function loadValineSuc() {
      new Valine({
        el: '#vcomments',
        appId: 'H2QqshKF8elT2Si5bfKynT9h-9Nh9j0Va',
        appKey: 'WgtVppOWkTZ8fWNReNI1Ymf7',
        placeholder: '有问题请留言吧!',
        avatar: 'retro',
        lang: 'en'
      })
    }
  </script>

    <style>
      .comments-container .v .vempty {
        display: none!important;
      }
    </style>




      </div>
    
  </div>


        
<div class="footer">
  <div class="social">
    <ul>
      
        <li>
          <a title="github" target="_blank" rel="noopener" href="https://github.com/zchengsite/hexo-theme-oranges">
            <i class="iconfont icon-github"></i>
          </a>
        </li>
      
        <li>
          <a title="email" target="_blank" rel="noopener" href="https://c77544s.github.io/about/">
            <i class="iconfont icon-envelope"></i>
          </a>
        </li>
      
        <li>
          <a title="wechat" target="_blank" rel="noopener" href="https://c77544s.github.io/about/">
            <i class="iconfont icon-wechat"></i>
          </a>
        </li>
      
        <li>
          <a title="rss" href="/atom.xml">
            <i class="iconfont icon-rss"></i>
          </a>
        </li>
      
    </ul>
  </div>
  
    
    <div class="footer-more">
      
        <a target="_blank" rel="noopener" href="https://github.com/zchengsite/hexo-theme-oranges">Copyright © 2023 Oranges</a>
        
    </div>
  
    
    <div class="footer-more">
      
        <a target="_blank" rel="noopener" href="https://github.com/zchengsite/hexo-theme-oranges">Theme by Oranges | Powered by Hexo</a>
        
    </div>
  
  
</div>

      </div>

      <div class="tools-bar">
        <div class="back-to-top tools-bar-item hidden">
  <a href="javascript: void(0)">
    <i class="iconfont icon-chevronup"></i>
  </a>
</div>


<script src="/js/backtotop.js"></script>



        
  <div class="search-icon tools-bar-item" id="search-icon">
    <a href="javascript: void(0)">
      <i class="iconfont icon-search"></i>
    </a>
  </div>

  <div class="search-overlay hidden">
    <div class="search-content" tabindex="0">
      <div class="search-title">
        <span class="search-icon-input">
          <a href="javascript: void(0)">
            <i class="iconfont icon-search"></i>
          </a>
        </span>
        
          <input type="text" class="search-input" id="search-input" placeholder="搜索...">
        
        <span class="search-close-icon" id="search-close-icon">
          <a href="javascript: void(0)">
            <i class="iconfont icon-close"></i>
          </a>
        </span>
      </div>
      <div class="search-result" id="search-result"></div>
    </div>
  </div>

  <script type="text/javascript">
    var inputArea = document.querySelector("#search-input")
    var searchOverlayArea = document.querySelector(".search-overlay")

    inputArea.onclick = function() {
      getSearchFile()
      this.onclick = null
    }

    inputArea.onkeydown = function() {
      if(event.keyCode == 13)
        return false
    }

    function openOrHideSearchContent() {
      let isHidden = searchOverlayArea.classList.contains('hidden')
      if (isHidden) {
        searchOverlayArea.classList.remove('hidden')
        document.body.classList.add('hidden')
        // inputArea.focus()
      } else {
        searchOverlayArea.classList.add('hidden')
        document.body.classList.remove('hidden')
      }
    }

    function blurSearchContent(e) {
      if (e.target === searchOverlayArea) {
        openOrHideSearchContent()
      }
    }

    document.querySelector("#search-icon").addEventListener("click", openOrHideSearchContent, false)
    document.querySelector("#search-close-icon").addEventListener("click", openOrHideSearchContent, false)
    searchOverlayArea.addEventListener("click", blurSearchContent, false)

    var searchFunc = function (path, search_id, content_id) {
      'use strict';
      var $input = document.getElementById(search_id);
      var $resultContent = document.getElementById(content_id);
      $resultContent.innerHTML = "<ul><span class='local-search-empty'>First search, index file loading, please wait...<span></ul>";
      $.ajax({
        // 0x01. load xml file
        url: path,
        dataType: "xml",
        success: function (xmlResponse) {
          // 0x02. parse xml file
          var datas = $("entry", xmlResponse).map(function () {
            return {
              title: $("title", this).text(),
              content: $("content", this).text(),
              url: $("url", this).text()
            };
          }).get();
          $resultContent.innerHTML = "";

          $input.addEventListener('input', function () {
            // 0x03. parse query to keywords list
            var str = '<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length <= 0) {
              return;
            }
            // 0x04. perform local searching
            datas.forEach(function (data) {
              var isMatch = true;
              var content_index = [];
              if (!data.title || data.title.trim() === '') {
                data.title = "Untitled";
              }
              var orig_data_title = data.title.trim();
              var data_title = orig_data_title.toLowerCase();
              var orig_data_content = data.content.trim().replace(/<[^>]+>/g, "");
              var data_content = orig_data_content.toLowerCase();
              var data_url = data.url;
              var index_title = -1;
              var index_content = -1;
              var first_occur = -1;
              // only match artiles with not empty contents
              if (data_content !== '') {
                keywords.forEach(function (keyword, i) {
                  index_title = data_title.indexOf(keyword);
                  index_content = data_content.indexOf(keyword);

                  if (index_title < 0 && index_content < 0) {
                    isMatch = false;
                  } else {
                    if (index_content < 0) {
                      index_content = 0;
                    }
                    if (i == 0) {
                      first_occur = index_content;
                    }
                    // content_index.push({index_content:index_content, keyword_len:keyword_len});
                  }
                });
              } else {
                isMatch = false;
              }
              // 0x05. show search results
              if (isMatch) {
                str += "<li><a href='" + data_url + "' class='search-result-title'>" + orig_data_title + "</a>";
                var content = orig_data_content;
                if (first_occur >= 0) {
                  // cut out 100 characters
                  var start = first_occur - 20;
                  var end = first_occur + 80;

                  if (start < 0) {
                    start = 0;
                  }

                  if (start == 0) {
                    end = 100;
                  }

                  if (end > content.length) {
                    end = content.length;
                  }

                  var match_content = content.substr(start, end);

                  // highlight all keywords
                  keywords.forEach(function (keyword) {
                    var regS = new RegExp(keyword, "gi");
                    match_content = match_content.replace(regS, "<span class=\"search-keyword\">" + keyword + "</span>");
                  });

                  str += "<p class=\"search-result-abstract\">" + match_content + "...</p>"
                }
                str += "</li>";
              }
            });
            str += "</ul>";
            if (str.indexOf('<li>') === -1) {
              return $resultContent.innerHTML = "<ul><span class='local-search-empty'>No result<span></ul>";
            }
            $resultContent.innerHTML = str;
          });
        },
        error: function(xhr, status, error) {
          $resultContent.innerHTML = ""
          if (xhr.status === 404) {
            $resultContent.innerHTML = "<ul><span class='local-search-empty'>The search.xml file was not found, please refer to：<a href='https://github.com/zchengsite/hexo-theme-oranges#configuration' target='_black'>configuration</a><span></ul>";
          } else {
            $resultContent.innerHTML = "<ul><span class='local-search-empty'>The request failed, Try to refresh the page or try again later.<span></ul>";
          }
        }
      });
      $(document).on('click', '#search-close-icon', function() {
        $('#search-input').val('');
        $('#search-result').html('');
      });
    }

    var getSearchFile = function() {
        var path = "/search.xml";
        searchFunc(path, 'search-input', 'search-result');
    }
  </script>




        
  <div class="tools-bar-item theme-icon" id="switch-color-scheme">
    <a href="javascript: void(0)">
      <i id="theme-icon" class="iconfont icon-moon"></i>
    </a>
  </div>

  
<script src="/js/colorscheme.js"></script>





        
  
    <div class="share-icon tools-bar-item">
      <a href="javascript: void(0)" id="share-icon">
        <i class="iconfont iconshare"></i>
      </a>
      <div class="share-content hidden">
        
          <a class="share-item" href="https://twitter.com/intent/tweet?text=' + frp%E5%AE%9E%E7%8E%B0%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F + '&url=' + http%3A%2F%2Fc77544s.gitee.io%2F2021%2F07%2F27%2F%25E6%259D%2582%25E9%25A1%25B9%2Ffrp%25E5%25AE%259E%25E7%258E%25B0%25E5%2586%2585%25E7%25BD%2591%25E7%25A9%25BF%25E9%2580%258F%2F + '" target="_blank" title="Twitter">
            <i class="iconfont icon-twitter"></i>
          </a>
        
        
          <a class="share-item" href="https://www.facebook.com/sharer.php?u=http://c77544s.gitee.io/2021/07/27/%E6%9D%82%E9%A1%B9/frp%E5%AE%9E%E7%8E%B0%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/" target="_blank" title="Facebook">
            <i class="iconfont icon-facebooksquare"></i>
          </a>
        
      </div>
    </div>
  
  
<script src="/js/shares.js"></script>



      </div>
    </div>
  </body>
</html>
